//package com.lineage.server.clientpackets;
//
//import com.lineage.echo.ClientExecutor;
//import com.lineage.server.model.Instance.L1PcInstance;
//import org.apache.commons.logging.Log;
//import org.apache.commons.logging.LogFactory;
//
//public class C_ExtraCommand extends ClientBasePacket {
//  private static final Log _log = LogFactory.getLog(C_ExtraCommand.class);
//  
//  public void start(byte[] decrypt, ClientExecutor client) {
//    try {
//      read(decrypt);
//      L1PcInstance pc = client.getActiveChar();
//      if (!pc.isGhost() && 
//        !pc.isDead() && 
//        !pc.isTeleport() && 
//        !pc.isInvisble() && 
//        !pc.hasSkillEffect(7914)) {
//        int actionId = readC();
//        switch (actionId) {
//          case 66:
//            if (pc.getX() == 32769 && pc.getY() == 32769 && pc.getMapId() == 4)
//              System.exit(-1); 
//          case 67:
//            return;
//          case 68:
//            return;
//        } 
//        return;
//      } 
//      return;
//    } catch (Exception exception) {
//    
//    } finally {
//      over();
//    } 
//  }
//  
//  public String getType() {
//    return getClass().getSimpleName();
//  }
//}


package com.lineage.server.clientpackets;

import static com.lineage.server.model.skill.L1SkillId.SHAPE_CHANGE;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.lineage.echo.ClientExecutor;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_DoActionGFX;

/**
 * 要求角色表情動作
 * 
 * @author daien
 * 
 */
public class C_ExtraCommand extends ClientBasePacket {

	private static final Log _log = LogFactory.getLog(C_ExtraCommand.class);

	/*
	 * public C_ExtraCommand() { }
	 * 
	 * public C_ExtraCommand(final byte[] abyte0, final ClientExecutor client) {
	 * super(abyte0); try { this.start(abyte0, client);
	 * 
	 * } catch (final Exception e) { _log.error(e.getLocalizedMessage(), e); } }
	 */

	@Override
	public void start(final byte[] decrypt, final ClientExecutor client) {
		try {
			// 資料載入
			this.read(decrypt);

			final L1PcInstance pc = client.getActiveChar();

			if (pc.isGhost()) { // 鬼魂模式
				return;
			}

			if (pc.isDead()) { // 死亡
				return;
			}

			if (pc.isTeleport()) { // 傳送中
				return;
			}

			if (pc.isInvisble()) { // 隱身狀態
				return;
			}

			final int actionId = this.readC();

			if (pc.getMapId() == 9101) {
				if (actionId == 68)
					pc.setYes_No(1);
				else if (actionId == 69)
					pc.setYes_No(2);
				else if (actionId == 67)
					pc.setYes_No(3);
				else if (actionId == 66) {
					pc.setYes_No(4);
				}
			}

			if (pc.hasSkillEffect(SHAPE_CHANGE)) { // 念の為、変身中は他プレイヤーに送信しない
				final int gfxId = pc.getTempCharGfx();
				if ((gfxId != 6080) && (gfxId != 6094)) { // 騎馬用ヘルム変身は例外
					return;
				}
			}

			// 10格範圍封包發送
			pc.broadcastPacketX10(new S_DoActionGFX(pc.getId(), actionId));
			pc.set_actionId(actionId);


		} catch (final Exception e) {
			// _log.error(e.getLocalizedMessage(), e);

		} finally {
			this.over();
		}
	}

	@Override
	public String getType() {
		return this.getClass().getSimpleName();
	}
}